<template>
  <div></div>
  <el-form :model="form" label-width="auto" style="max-width: 100%">
    <el-form-item label="任务标题">
      <el-input v-model="form.title" />
    </el-form-item>
    <el-form-item label="任务类型">
      <el-select v-model="form.type" placeholder="请选择任务类型">
        <el-option label="待办型" value= 0 />
        <el-option label="通知型" value= 1 />
        <el-option label="计时型" value= 2 />
      </el-select>
    </el-form-item>

    <el-form-item label="任务描述">
      <el-input v-model="form.content" type="textarea" />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">Create</el-button>
      <el-button>Cancel</el-button>
    </el-form-item>
  </el-form>
</template>

<script lang="ts" setup>
import {getCurrentInstance, reactive} from 'vue'
import {Action, ElMessage, ElMessageBox} from "element-plus";
const {appContext: {config: {globalProperties: global}}} = getCurrentInstance();//3.0.11
// do not use same name with ref
const form = reactive({
  title: '',
  content: '',
  type: '',
})

const onSubmit = () => {
  global.$request.post('/systemTask/addSystemTask',form)
  ElMessageBox.alert('发布成功！', '系统任务发布', {

    confirmButtonText: 'OK',
    callback: (action: Action) => {
      ElMessage({
        type: 'info',
        message: `action: ${action}`,
      })
    },
  })
}
</script>
